package com.ht.system.api.factory;

import com.ht.common.core.domain.R;
import com.ht.system.api.RemoteBaseFieldInfoService;
import com.ht.system.api.dto.BaseFieldInfoDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 场站信息服务降级处理
 *
 * @author zmx
 */
@Component
public class RemoteBaseFieldInfoFallbackFactory implements FallbackFactory<RemoteBaseFieldInfoService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteBaseFieldInfoFallbackFactory.class);


    @Override
    public RemoteBaseFieldInfoService create(Throwable throwable) {
        return new RemoteBaseFieldInfoService() {
            @Override
            public R<BaseFieldInfoDto> findByFieldCode(String fieldCode, String source) {
                return R.fail("获取场站信息失败:" + throwable.getMessage());
            }

            @Override
            public R<List<BaseFieldInfoDto>> findListByCustomsCode(String customsCode, String source) {
                return R.fail("获取场站信息列表失败:" + throwable.getMessage());
            }

            @Override
            public R<List<BaseFieldInfoDto>> findAllFieldInfo(String source) {
                return R.fail("获取所有场站信息列表失败:" + throwable.getMessage());
            }
        };
    }
}
